Trying to make a ui manager for a decal thingy but no work

local decalId = script.Parent.DecalBox.Text
local submitButton = script.Parent.SubmitButton
local decalIdSubmitEvent = game:GetService("ReplicatedStorage"):WaitForChild("DecalIdSubmitEvent")

submitButton.MouseButton1Click:Connect(function()
	decalIdSubmitEvent:FireServer(decalId)
	print(decalId)
	print("Decal Id successfully sent")
end)

local script

handler for texture

local decalIdSubmitEvent = game:GetService("ReplicatedStorage"):WaitForChild("DecalIdSubmitEvent")

decalIdSubmitEvent.OnServerEvent:Connect(function(player, decalId)
	print(decalId)
	
	print("Successfully recieved")
	
	local texture = "http://www.roblox.com/asset/?id="..decalId

	local decal = Instance.new("Decal")
	decal.Texture = texture
	decal.Parent = script.Parent.WhiteBoard
	decal.Face = "Back"
	print("Changed")
	
end)

No errors, but it does even print anything for line 4 of local script. Any ideas? Text is 100% all good and stuff…
image
image

I’m sorry, I don’t quite understand what you mean with nothing getting printed “for line 4 of local script”. Are you referring to the click detection?

change line 4 to
local decalId = tonumber(script.Parent.DecalBox.Text)
because it will stay as a string if you dont, so if you pass the decalId to the another script it may error thus;

local decalId = tonumber(script.Parent.DecalBox.Text)
local submitButton = script.Parent.SubmitButton
local decalIdSubmitEvent = game:GetService("ReplicatedStorage"):WaitForChild("DecalIdSubmitEvent")

submitButton.MouseButton1Click:Connect(function()
	decalIdSubmitEvent:FireServer(decalId)
	print(decalId)
	print("Decal Id successfully sent")
end)
	print(decalId)

This part

It prints “nil” using the tonumber() functionality

Fixed it:
local script

local decalIdSubmitEvent = game:GetService("ReplicatedStorage"):WaitForChild("DecalIdSubmitEvent")

script.Parent.Changed:Connect(function()
	if script.Parent.Text ~= nil and script.Parent.Text ~= "" then
		decalIdSubmitEvent:FireServer(script.Parent.Text)
	end
end)

script:

local decalIdSubmitEvent = game:GetService("ReplicatedStorage"):WaitForChild("DecalIdSubmitEvent")

decalIdSubmitEvent.OnServerEvent:Connect(function(player, decalId)
	local decal = Instance.new("Decal")
	decal.Texture = "http://www.roblox.com/asset/?id="..decalId
	decal.Parent = script.Parent.WhiteBoard
	decal.Face = "Back"	
end)

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.