Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

Script that shows GUI when stepped on a part works in studio but not in the roblox game?

My script that i made is supposed to show an GUI when you step on the specific block. It works on studio but not ingame. Could someone help me ? here is the script:

script.Parent.Touched:connect(function(hit)
	if hit.Name == ("Right Leg") or hit.Name == ("Left Leg") then
for i,v in pairs(game.Players:GetPlayers()) do
	v.Character.Torso.CFrame = v.Character.Torso.CFrame * CFrame.new(2,2,2)
local cam = workspace.CurrentCamera
cam.CFrame = workspace.carroom.Cam.CFrame
cam.CameraType = "Scriptable"
v.PlayerGui.Upgradeshop.Enabled = true
for a,k in pairs(v:GetChildren()) do
	if k:IsA("Model") then
		k:Destroy()
	end
end
wait(1)
if v.SelectedCar.Value == nil then
	v.PlayerGui.Upgradeshop.TextLabel.Visible = true
end
local d = v.SelectedCar.Value:Clone()
d:SetPrimaryPartCFrame(game.Workspace.carroom.carspawn.CFrame * CFrame.fromEulerAnglesXYZ(0,0,1.55) * CFrame.new(-1,1,0))
d.Parent = cam
v.PlayerGui.Upgradeshop.Frame.Visible = true
wait(0.1)
while wait() do
	d:SetPrimaryPartCFrame(d.Body.Base.CFrame * CFrame.fromEulerAnglesXYZ(0,.1,0))
end
end
	end
end)

1 answer

Is your script FE? If not, then set it to be, you won't regret it, trust me. You should put the part of the script that makes the gui appear in a local script inside the player and tie it with the script which detects the touch using a remoteevent (if you want the gui to appear on all players, just do :FireAllClients (or something like that))

If you don't understand, you should probably look up remote events.

1 comment

0

Sadly, that didnt work. I tried OnServerEvent and it works an studio, but not ingame and it shows an error ingame that it only works for the server. Then i tried OnClientEvent and it didnt work for both. did i do something wrong?

This discussion is preserved as it was. New answers, comments, and votes are closed.