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

This does not work in a server but works in studio so I am confused????


script.Parent.Touched:connect(function(char)
	local  player  = game.Players:GetPlayerFromCharacter(char.Parent)
	player:WaitForChild("PlayerGui"):WaitForChild("Level1GUI").TextLabel:TweenPosition(UDim2.new(0.5, 0,0.5, 0),"In","Sine")
	wait(3)
	player.PlayerGui.Level1GUI.TextLabel:TweenPosition(UDim2.new(0.5, 0,-0.5, 0),"Out","Sine")
	player.PlayerGui:WaitForChild("Level1INFO").TextLabel.Text =  workspace.Stage1.Info.Value
	player:WaitForChild("PlayerGui").Level1INFO.TextLabel:TweenPosition(UDim2.new(0.5, 0,0.5, 0),"In","Sine")
	wait(8)
	player.PlayerGui.Level1INFO.TextLabel:TweenPosition(UDim2.new(0.5, 0,-0.5, 0),"In","Sine")	
	
end)

2 answers

You should never access GUIS with a ServerScript.

Instead, a LocalScript is better.

local Part = game.Workspace:WaitForChild('Object') -- Assuming you wrote this code, you must know how to define a variable.
local plr = game.Players.LocalPlayer
local Level1GUI = plr:FindFirstChild('PlayerGui'):WaitForChild('Level1GUI')
local Level1INFO = plr:FindFirstChild('PlayerGui'):WaitForChild('Level1INFO')

Part.Touched:Connect(function()
	Level1GUI.TextLabel:TweenPosition(UDim2.new(0.5,0,0.5),'In','Sine',2.5) -- you made a mistake here
	wait(3)
	Level1GUI.TextLabel:TweenPosition(UDim2.new(0.5, 0,-0.5),"Out","Sine",2.5) -- made same mistake with tweening
	Level1INFO.TextLabel:TweenPosition(UDim2.new(0.5, 0,0.5),"In","Sine",2.5) -- duno why you made mistake for all of them
	wait(8)
	Level1INFO.TextLabel:TweenPosition(UDim2.new(0.5, 0,-0.5),"In","Sine",2.5)  
end)

Should work if you know how to change this to your desire, else, you just copied this code full of errors. If this doesn't work, comment on this answer and I will help you.

If this helped you in anyway, please Upvote and accept answer. Thank you.

Always learn the basics before making a game

-- Your Orange, BlackOrange3343

PS: Good Luck on your game!

3 comments

0

Did not work

0

Should work if you knew how to change it

0

If you just copy pasted it won't work

local Part = workspace.LevelShowerBricks:WaitForChild('Level1') local plr = game.Players.LocalPlayer local Level1GUI = plr:FindFirstChild('PlayerGui'):WaitForChild('Level1GUI') local Level1INFO = plr:FindFirstChild('PlayerGui'):WaitForChild('Level1INFO')

Part.Touched:connect(function() Level1GUI.TextLabel:TweenPosition(UDim2.new(0.5,0,0.5),'In','Sine',2.5) -- you made a mistake here wait(3) Level1GUI.TextLabel:TweenPosition(UDim2.new(0.5, 0,-0.5),"Out","Sine",2.5) -- made same mistake with tweening Level1INFO.TextLabel:TweenPosition(UDim2.new(0.5, 0,0.5),"In","Sine",2.5) -- duno why you made mistake for all of them wait(8) Level1INFO.TextLabel:TweenPosition(UDim2.new(0.5, 0,-0.5),"In","Sine",2.5)
end)

1 comment

0

I did that

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