Visible is not a valid member of PlayerGui "Players.MsveNezers.PlayerGui" - lua

I've tried everything, nothing works for me, I need to open the store menu when touching Part. And so that this menu does not open for all players
local open = game.Workspace.openPart
local close = game.Workspace.closePart
local frame = script.Parent
frame.Visible = false
local function Shop (otherPart)
local player = game.Players:FindFirstChild(otherPart.Parent.Name)
if player then
player.PlayersGui.Shop.Frame.Visible = true
end
end
open.Touched:Connect(Shop)
I looked at different sources for a solution to my problem, tried to change my code, but nothing happened
enter image description here
enter image description here
enter image description here

Related

Script doesn't seem to be working, and I cannot understand why

script dont work
I am incredibly new to scripting, and I was just fooling around in ROBLOX studio and I made a script that was INTENDED to put an item stored in ReplicatedStorage into a specific players StarterPack, but no matter what I change it does not want to work.
Could anyone explain why?
local playerName = "plr name"
local toolName = "tool name"
game.Players.PlayerAdded:Connect(function(player)
if player.Name == playerName then
local tool = game.ReplicatedStorage:FindFirstChild(toolName)
player.StarterPack:AddItem(tool)
end
end)
You are using an :AddItem() function which doesn't work. You must first clone the tool and add it into the players inventory.
Check the documentation on StarterPack if you are having issues: https://create.roblox.com/docs/reference/engine/classes/StarterPack
Try this:
local playerName = "plr name"
local toolName = "tool name"
local tool = game.ReplicatedStorage:FindFirstChild(toolName)
game.Players.PlayerAdded:Connect(function(player)
if player.Name == playerName then
local newTool = tool:Clone()
newTool.Parent = player.Backpack
end)
end`
The StarterPack is used to determine a set of Tools that all players will spawn with. If a developer wants to ensure that certain Tools are available to specific players, then they will need to parent the Tools directly to the player's Backpack instead.
Your code is mostly fine, but you didn't close your PlayerAdded function, and the StarterPack doesn't have an AddItem function.
If you are having issues, you can always check the documentation for the StarterPack. One issue that I think you'll run into is that putting a tool into the StarterPack will give it to all players, not just the one who matches the name.
The StarterPack is used to determine a set of Tools that all players will spawn with. If a developer wants to ensure that certain Tools are available to specific players, then they will need to parent the Tools directly to the player's Backpack instead.
So instead let's clone the tool into the player's Backpack. But since the backpack gets cleared every time the player respawns, let's move this code into the CharacterAdded event, so it fires every time the character loads into the Workspace.
local playerName = "plr name"
local toolName = "tool name"
local tool = game.ReplicatedStorage:FindFirstChild(toolName)
game.Players.PlayerAdded:Connect(function(player)
if player.Name == playerName then
player.CharacterAdded:Connect(function()
local newTool = tool:Clone()
newTool.Parent = player.Backpack
end)
end
end)

Roblox Lua: Issue defining a value in a player's leaderstats folder (no error message)

I have a system in my game where when a player steps on a checkpoint, a Stage value in the leaderboard will go up, and then that value is saved to that player's userId.
I want there to be a button that resets that value back to 0, and this is the code I tried for it.
local textButton = script.Parent
local Players = game:GetService("Players")
textButton.MouseButton1Up:Connect(function()
local player = game.Players.LocalPlayer
local stage = Players:WaitForChild(player):WaitForChild("leaderstats").Stage
if stage.Value > 1 then
stage.Value = 1
end
end)
I've tried debugging it by putting print commands in different places to see where the code gets, and when I try to run print(stage) it does not show anything.
LocalScripts cannot change the value on the server. To change a value once a button is clicked, RemoteEvents should be used.
There is a page documenting about them here: https://create.roblox.com/docs/scripting/networking/remote-events-and-functions
To use a RemoteEvent, first you need to put it in a place that is replicated across the server and the client. A good example of this would be to put it in ReplicatedStorage. After that, you need to set up a script that listens for the .OnServerEvent event of the RemoteEvent. To do this, you need to connect a function. As seen in your script, you already know how to do this. So I will get straight to the point.
On the server, set up a script that listens for .OnServerEvent. Next, on the client, edit your script to fire the client instead of trying to set the value. Go back to the server script, and set the value there. The event also passes the Player object, so you can utilize that to actually reset the value.
TLDR;
LocalScript inside of your TextButton:
local textButton = script.Parent
local Players = game:GetService("Players")
local RemoteEvent = 'RemoteEvent location'
textButton.MouseButton1Up:Connect(function()
RemoteEvent:FireServer()
end)
Server Script in anywhere, preferably ServerScriptService:
RemoteEvent.OnServerEvent:Connect(function(player)
local Players = game:GetService("Players")
local stage = Players:WaitForChild(player):WaitForChild("leaderstats").Stage
if stage.Value > 1 then
stage.Value = 1
end
end)
Good luck!

IntValue changing but not shown

I'm scripting a lawn-mowing game in Roblox Studio and I've come across a problem. So every time I cut the grass(trawa) the IntValue goes up by 1. It works fine when it is assigned to a pick-up object and the points go straight to Player's Inventory folder:
local trawa = script.Parent
local function collect(otherPart)
local player = game.Players:FindFirstChild(otherPart.Parent.Name)
if player then
local trawaType = trawa.Name
local trawaStat = player.Inventory:FindFirstChild(trawaType)
if trawaStat then
trawa:Destroy()
trawaStat.Value = trawaStat.Value + 1
end
end
end
trawa.Touched:Connect(collect)
So that script works fine, but that's not the way I want it to work. I want the points to be assigned directly after cutting grass, not after I collect a pick-up it drops. So I changed the script above so that the points are assigned to the tool's inventory and then are copied to player's inventory.
local trawa = script.Parent
local function onTouch(otherPart)
local tool = otherPart.Parent
if tool:IsA('Tool') and tool.Kosa.Value == true then
trawa.Parent = nil
local trawaType = trawa.Name
local trawaStat = tool.Inventory:FindFirstChild(trawaType)
trawaStat.Value = trawaStat.Value + 1
print(trawaStat.Value)
wait(3)
trawa.Parent = workspace
end
end
trawa.Touched:Connect(onTouch)
The value does indeed change because it goes up when I print it, but it's not changing in the properties and is not registered by other scripts, because it's not copied to player's inventory.
Then this is the script in ServerScriptService that should transfer points from the tool to player:
local starter = game:GetService("StarterPack")
local tool = starter:FindFirstChildWhichIsA('Tool')
local player = game:GetService("Players").LocalPlayer
function points(player)
player.Inventory.Trawa2.Value = player.Inventory.Trawa2.Value + tool.Inventory.Trawa2.Value
tool.Inventory.Trawa2.Value = 0
end
tool.Inventory.Trawa2.Changed:Connect(points)
Changing IntValue to NumberValue doesn't solve the problem.
Use a local script with a RemoteEvent that runs it in server script, local scripts are client side. So they don't save to the server, but if you run it on the server, it saves.
Click this link if you want to know more about RemoteEvents.
https://roblox.fandom.com/wiki/Class:RemoteEvent

Create phone and call friends in roblox studio

Hello I would like to know if someone knows how it would be possible to create a phone to call friends, for example you see the list of people connected on the phone and call one and when he answers you can have a private chat with him..
Any ideas or way to do this? I've looked everywhere and can't find a solution..
first, before we start making a chat function, we're going to need a list of players. Create a frame to be the phone, then add the following local script:
local frame = script.parent
local plrs = game:GetService("Players")
local plr = plrs.LocalPlayer
for i,v in pairs(plrs) do
if v.Name ~= plr.Name then
local optionButton = Instance.new("TextButton")
optionButton.Text = v.Name
optionButton.Parent = frame
optionButton.MouseButton1Click:Connect(function()
--They chose a player to talk to
--We're going to create a value on the player so we can remember who they're talking to:
local val = Instance.new("StringValue")
val.Name = "chattingTo"
val.Value = v.Name
val.Parent = plr
end)
end
end
When they click on that button, we know they want to chat to the player V. You could add in some sort of ringing system so the other player can choose to accept/decline the call, but that isn't important. For the chat, to communicate between players, we're going to need a remove event (called "ChatEvent" under Replicated Storage) and a scrolling frame for the messages to show on.
Make a localscript under the chat frame, with:
local rs = game:GetService("ReplicatedStorage")
local event = rs:WaitForChild("ChatEvent")
event.OnClientEvent:Connect(function(msg, from)
local textlabel = Instance.new("TextLabel")
textlabel.Text = from.Name..": "..msg
textlabel.Parent = script.Parent
end)
The script above will handle showing messages it receives. Now we want to be able to send messages, so add to the bottom of that localscript:
local inputBox = script.Parent.myTextBox --obviously change all variables to the route in your game
local sendButton = script.Parent.sendButton
local uis = game:GetService("UserInputService")
function sendChat()
local msgToSend = inputBox.Text
local sendTo = game.Players.LocalPlayer.chattingTo.Value
event:FireServer(sendTo, msgToSend)
local textlabel = Instance.new("TextLabel")
textlabel.Text = game.Players.LocalPlayer.Name..": "..msg
textlabel.Parent = script.Parent
end
sendButton.MouseButton1Click:Connect(sendChat)
uis.InputBegan:Connect(function(input)
if input.KeyCode == Enum.KeyCode.Return then
sendChat()
end
end)
So now whenever we either click the send button or press our enter/return key, it will fire an event on the server. And when an event on the client is fired by the server, it will add a message to the chat. Now we need to just join them together with the following (server) script:
local rs = game:GetService("ReplicatedStorage")
local event = rs:WaitForChild("ChatEvent")
event.OnServerEvent:Connect(function(from, to, msg)
--The variable 'to' is who we want to send it to - but it's a string! so:
local sendTo = game.Players[to]
event:FireClient(sendTo, msg, from)
end)
And that (should) be it. This would work, but it could face moderation action, as it doesn't use roblox's chat filter, so I recommend you integrate something with that.

script works but nothing happens in-game in roblox studio

I am having problems with the functionality of a script and I don't know how to solve it.
In the images below attach photos of the in-game problem, this means that the whole script works and in-game the property of the visible "bframe" is false but in-game this is not shown and I want to know how I can solve it ..
in-game mode the visibility of the "Bframe" it becomes false in the property (that's fine) but in-game this is not seen..
Does anyone know how to solve it?
Button script
-- Events
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local Evento = ReplicatedStorage.RemoteEvent
-- end of Events
local button = script.Parent
local frame = script.Parent.Parent.Parent.Frame
Evento.OnClientEvent:Connect(function(argumento1)
button.MouseButton1Click:Connect(function()
if frame.Visible == false then
frame.Visible = true
button.Visible = false
else
frame.Visible = false
end
end)
end)
Server script
-- Events
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local Evento = ReplicatedStorage.RemoteEvent
-- end of Events
game.Players.PlayerAdded:Connect(function(player)
Evento:FireClient(player,"argumento1")
print("testing probado")
end)
Redteam / touch part script called script
local wll = script.Parent.Part
local fr = game.StarterGui.TeamChangerGui.BFrame
local function Toch()
fr.Visible = false
fr.button.Visible = false
print("visible desactivado")
end
wll.Touched:Connect(function(hit)
if hit.Parent:FindFirstChild("Humanoid") then
Toch()
end
end)
**images**
enter image description here
enter image description here
enter image description here
Is the button script a localscript? if it is then it may be to do with the fireclient although I am not good at it and I usually use fireallclients passing through the player name then checking if its the correct name on the clients side script.
Otherwise I am not sure as it is an interesting issue i have never encountered. Hope it works!

Resources